<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>发布作业</title>
    <link href="bootstrap-4.6.1-dist/css/bootstrap.css"
          rel="stylesheet" type="text/css">
    <style>
        .dropdown{
            margin-bottom: -20px;
        }
        .dropdown:hover{
            margin: 0px;
        }
        .show{
            /*display: block;*/
            overflow: hidden;
            visibility: hidden;
            max-height: 0px;
            transform: scaleY(0);
        }
        .dropdown:hover .show{
            visibility: visible;
            overflow: hidden;
            transition: transform 0.2s;
            max-height: 999999px;
            transform: scaleY(1);
        }
        .userPortrait {
            width: 40px;
            height: 40px;
            border: 1px solid red;
            border-radius: 50%;
            overflow: hidden;
            margin: 0 auto;
            /*margin-top: 100px;*/
        }
        .userPortrait img {
            display: block;
            width: 100%;
            height:100%;
            border: 1px solid green;
        }
        .menu {
            width: 200%;
            float: left;
            padding: 15px;
            border: 1px solid black;
            margin-left: -16px;
        }
        .bt {
            position:fixed;
            display: inline-block;
            padding: 10px 20px;
            font-size: 18px;
            cursor: pointer;
            text-align: center;
            text-decoration: none;
            outline: none;
            color: #fff;
            background-color:dodgerblue;
            border: none;
            border-radius: 10px;
            box-shadow: 0 4px #999;
            right:3%;
        }

        .bt:hover {background-color:dodgerblue}

        .bt:active {
            background-color:dodgerblue;
            box-shadow: 0 5px #666;
            transform: translateY(4px);
        }
        .zt{
            size:14px;
            font-family: "黑体", "Courier New", monospace;
        }
    </style>
</head>
<body>

<!--眉头-->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
    <a class="navbar-brand col-1 text-center" href="index.html">爱思教育</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link active" href="#">老师,您好,请发布作业!</a>
            </li>
            <li class="nav-item active dropdown">
                <a class="nav-link " href="teacherHome.html" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                    主页
                </a>
            </li>
            <li class="nav-item active" id="release">
                <div class="nav-link " href="teacherCheckHomework.html" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                    批改作业
                </div>
            </li>
        </li>
        </ul>
    </div>
    <div class="userPortrait active dropdown">
        <a href="userInformation.html"><img src="img/defaultPortrait.jpg" alt=""></a>
    </div>
</nav>

<!--中间-->
<div class="row">
    <!--侧边栏-->
    <ul class="navbar-nav bg-light text-center col-md-2">
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">高等数学</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn1" href="#">3.1</button>
                <button class="dropdown-item" id="btn2" href="#">3.2</button>
            </div>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">计算机网络</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn3" href="#">4.1</button>
                <button class="dropdown-item" id="btn4" href="#">4.2</button>
            </div>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">操作系统</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn5" href="#">4.5</button>
                <a class="dropdown-item" id="btn6" href="#">4.9</a>
            </div>
        </li>
        <li class="nav-item dropdown">
            <a class="nav-link btn btn-light dropdown-toggle" href="#">Java基础</a>
            <div class="dropdown-menu text-center show">
                <button class="dropdown-item" id="btn7" href="#">4.5</button>
                <a class="dropdown-item" id="btn8" href="#">4.9</a>
            </div>
        </li>
    </ul>
    <!--主页面-->
    <div class="main col-10">
        <div class="main col-10 menu">
            <form id="form">
                <!--<input type="hidden" name="" id="uId">-->
                <div id="tbody">

                </div>
            </form>
        </div>
    </div>
    <div class="box">
            <button type="button" class="bt" id="homework">发布作业</button>
    </div>
</div>
<!--页脚-->
<div class="footer bg-primary fixed-bottom text-center">
    <p class="text-white">版权所有© Copyright 1999-2021 爱思软件股份有限公司　　中国·青岛黄岛区嘉陵江路777号 西区公寓2号   版本V-0.0.1</p>
</div>

</body>
<script src="jquery/jquery-3.6.0.min.js"></script>
<script>

    //let str=sessionStorage.getItem("info");
    //let param=JSON.parse(str);
    jQuery(function(){
       //jQuery("#uId").val(u.userId);
        jQuery("#homework").click(function(){
            let form=jQuery("form").serialize();
            jQuery.post("teacher/reg",form,function (rst) {
                alert(rst);
            })
        })
    })

    jQuery(function () {
        var loc = location.href;
        var n1 = loc.length;//地址的总长度
        var n2 = loc.indexOf("=");//取得=号的位置
        var param = decodeURI(loc.substr(n2+1, n1-n2));//从=号后面的内容
        alert(param);
        jQuery("#btn1").click(function () {
            let form=jQuery("#form").serialize();<!-- 获取表单的数据-->
            jQuery.post("teacher/search",form,function (rst) {
                let trs='';
                var m=new Array(rst.length);
                for(let i=0;i<rst.length;i++)
                {
                    let u=rst[i];
                    if(u.type==1) {
                            trs = `
                    <input class="form-check-input1" name="ids" type="checkbox" value="${u.question}|${u.answer}|${u.type}|${param}" >
                    <label class="zt" id="Question" name="Question">
                        ${u.question}
                    </label>
                    <br>
                    <label class="zt" id="Right_Answer" name="Right_Answer">
                        &emsp;正确答案:${u.answer}
                    </label>
                    <br>`;
                            jQuery("#tbody").append(trs);
                    }
                    else{
                        let tm=u.question.split('A');
                        let ta=tm[1].split('B');
                        let tb=ta[1].split('C');
                        let tc=tb[1].split('D');
                        let ans=u.answer?'A':u.answer?'B':u.answer?'C':'D';
                        let ba,bb,bc,bd;
                        if(ans=='A') ba="checked";
                        else if(ans=='B') bb="checked";
                        else if(ans=='C') bc="checked";
                        else bd="checked";
                        trs = `<input class="form-check-input1" name="ids" type="checkbox" value="${u.question}|${u.answer}|${u.type}|${param}" id="defaultCheck1">
                <label class="zt" for="defaultCheck1">
                    ${tm[0]}
                </label>
                <br>
                <label class="zt" for="defaultCheck1">
                    &emsp;&emsp;&emsp;
                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="" checked=ba>

                    <label class="form-check-label" for="inlineRadio1">
                        A:${ta[0]}
                    </label>
                    <br>
                    &emsp;&emsp;&emsp;
                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="" checked=bb>
                    <label class="form-check-label" for="inlineRadio2">B:${tb[0]}</label>
                    <br>
                    &emsp;&emsp;&emsp;
                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="" checked=bc>
                    <label class="form-check-label" for="inlineRadio3">C:${tc[0]}</label>
                    <br>
                    &emsp;&emsp;&emsp;
                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio4" value="" checked=bd>
                    <label class="form-check-label" for="inlineRadio4">D:${tc[1]}</label>
                </label>
                <br>`;
                        jQuery("#tbody").append(trs);
                    }

                }
            })
        })
    })
</script>
<script>
    jQuery(function () {
        jQuery("#release").click(function () {
            let loc = location.href;
            let n1 = loc.length;
            let n2 = loc.indexOf("=");
            let id = decodeURI(loc.substr(n2+1, n1-n2));
            location.href="teacherReleaseHomework.html?"+"id="+encodeURI(id);
        })
    })
</script>
</html>
